package org.ling.xuan.util;

import cn.hutool.core.util.StrUtil;
import org.ling.xuan.entity.HundSonInfo;
import org.ling.xuan.entity.HundSunVersionCheckFile;

public class HundSunParseUtil {

    public static HundSonInfo parse(String content, HundSonInfo hundSonInfo) {
        if (hundSonInfo == null) {
            hundSonInfo = new HundSonInfo();
        }
        if (StrUtil.isNotBlank(content)) {
            HundSunVersionCheckFile file = new HundSunVersionCheckFile(content);
            //头部注释区域
            hundSonInfo.setAnnotationText(file.getAnnotationRangeContent());
            //文件版本
            hundSonInfo.setAnnotationVersionText(file.getAnnotationFieldText("系统版本"));
            hundSonInfo.setAnnotationVersion(file.getAnnotationField("系统版本"));
            //文件开发者
            hundSonInfo.setAnnotationAuthText(file.getAnnotationFieldText("开发人员"));
            hundSonInfo.setAnnotationAuth(file.getAnnotationField("开发人员"));
            //文件名称
            hundSonInfo.setAnnotationFileNameText(file.getAnnotationFieldText("文件名称"));
            hundSonInfo.setAnnotationFileName(file.getAnnotationField("文件名称"));

            //最后修改信息
            hundSonInfo.setLastAnnotationText(file.getLastAnnotationText());
            hundSonInfo.setLastAnnotationContent(file.getLastAnnotationContent());
            //版本号
            hundSonInfo.setLastAnnotationVersion(file.getLastAnnotationVersionContent());
            //修改单号
            hundSonInfo.setLastAnnotationModifyId(file.getLastModifyNo());
            // HUNDDSUN整体内容
            hundSonInfo.setHundSonColText(file.getHundSunFieldText());
            //lastmodify
            hundSonInfo.setHundSonDateText(file.getHundSunFieldAnoText("lastModiDate"));
            hundSonInfo.setHundSonDate(file.getHundSunFieldAnoValue("lastModiDate"));
            //version
            hundSonInfo.setHundSonVersionText(file.getHundSunFieldVersionText());
            hundSonInfo.setHundSonVersion(file.getHundSunFieldVersion());
            //des
            hundSonInfo.setHundSonDesText(file.getHundSunFieldAnoText("describe"));
            hundSonInfo.setHundSonDes(file.getHundSunFieldAnoValue("describe"));
            //方法版本代码
            hundSonInfo.setMethodVersionText(file.getVersionMethodText());
            //方法版本信息
            hundSonInfo.setMethodVersion(file.getVersionMethodValue());
        }
        return hundSonInfo;
    }
}
